﻿<!DOCTYPE html>
<html>
<head>
  <title>配偶信息</title>
  <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
  <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
  <meta name="apple-mobile-web-app-capable" content="yes"/>
  <link href="/resources/resources/css/jquery-ui-themes.css" type="text/css" rel="stylesheet"/>
  <link href="/resources/resources/css/axure_rp_page.css" type="text/css" rel="stylesheet"/>
  <link href="/resources/data/styles.css" type="text/css" rel="stylesheet"/>
  <link href="/resources/files/配偶信息/styles.css" type="text/css" rel="stylesheet"/>
  <script src="/resources/resources/scripts/jquery-1.7.1.min.js"></script>
  <script src="/resources/resources/scripts/jquery-ui-1.8.10.custom.min.js"></script>
  <style>

  </style>
</head>
<body>
<div id="base" class="">
  <div id="yin">
    <!-- Unnamed (矩形) -->
    <div id="u273" class="ax_default box_1">
      <div id="u273_div" class=""></div>
      <div id="u273_text" class="text ">
        <p><span>流动人口服务管理系统</span></p>
      </div>
    </div>

    <!-- Unnamed (矩形) -->
    <div id="u329" class="ax_default box_1" onclick="toPersonalMessage()">
      <div id="u329_div" class=""></div>
      <div id="u329_text" class="text ">
        <p><span>个人信息</span></p>
      </div>
    </div>

    <!-- Unnamed (水平线) -->
    <div id="u318" class="ax_default line">
      <img id="u318_img" class="img " src="images/个人信息/u170.png"/>
    </div>

  </div>


  <!-- Unnamed (矩形) -->
  <div id="u274" class="ax_default box_1">
    <div id="u274_div" class=""></div>
    <div id="u274_text" class="text ">
      <p><span>配偶姓名：</span></p>
    </div>
  </div>
  <form  id="form2" enctype="multipart/form-data" method="post" accept-charset="utf-8">
  <!-- Unnamed (文本框) -->
  <div id="u275" class="ax_default text_field">
    <input id="u275_input" name="name" required="required"  type="text" value=""/>
  </div>

  <!-- Unnamed (矩形) -->
  <div id="u276" class="ax_default box_1">
    <div id="u276_div" class=""></div>
    <div id="u276_text" class="text ">
      <p><span>配偶身份号码：</span></p>
    </div>
  </div>

  <!-- Unnamed (矩形) -->
  <div id="u277" class="ax_default box_1">
    <div id="u277_div" class=""></div>
    <div id="u277_text" class="text ">
      <p><span>现居住地地址：</span></p>
    </div>
  </div>

  <!-- Unnamed (文本框) -->
  <div id="u278" class="ax_default text_field">
    <input id="u278_input" required="required" name="identify" type="text" value=""/>
  </div>

  <!-- Unnamed (矩形) -->
  <div id="u296" class="ax_default box_1">
    <div id="u296_div" class=""></div>
    <div id="u296_text" class="text ">
      <p><span>省</span></p>
    </div>
  </div>

  <!-- Unnamed (文本框) -->
  <div id="u297" class="ax_default text_field">
    <input id="u297_input" type="text" value=""/>
  </div>

  <!-- Unnamed (矩形) -->
  <div id="u298" class="ax_default box_1">
    <div id="u298_div" class=""></div>
    <div id="u298_text" class="text ">
      <p><span>省</span></p>
    </div>
  </div>

  <!-- Unnamed (文本框) -->
  <div id="u299" class="ax_default text_field">
    <input id="u299_input" name="detailedAddress" type="text" value=""/>
  </div>

  <!-- Unnamed (文本框) -->
  <div id="u300" class="ax_default text_field">
    <input id="u300_input" type="text" value=""/>
  </div>

  <!-- Unnamed (矩形) -->
  <div id="u301" class="ax_default box_1">
    <div id="u301_div" class=""></div>
    <div id="u301_text" class="text ">
      <p><span>市</span></p>
    </div>
  </div>

  <!-- Unnamed (矩形) -->
  <div id="u302" class="ax_default box_1">
    <div id="u302_div" class=""></div>
    <div id="u302_text" class="text ">
      <p><span>市</span></p>
    </div>
  </div>

  <!-- Unnamed (矩形) -->
  <div id="u303" class="ax_default box_1">
    <div id="u303_div" class=""></div>
    <div id="u303_text" class="text ">
      <p><span>县（区）</span></p>
    </div>
  </div>

  <!-- Unnamed (矩形) -->
  <div id="u304" class="ax_default box_1">
    <div id="u304_div" class=""></div>
    <div id="u304_text" class="text ">
      <p><span>乡（镇、街办）</span></p>
    </div>
  </div>

  <!-- Unnamed (文本框) -->
  <div id="u305" class="ax_default text_field">
    <input id="u305_input" name="nowInVillage" type="text" value=""/>
  </div>

  <!-- Unnamed (矩形) -->
  <div id="u306" class="ax_default box_1">
    <div id="u306_div" class=""></div>
    <div id="u306_text" class="text ">
      <p><span>村（社区）</span></p>
    </div>
  </div>

  <!-- Unnamed (矩形) -->
  <div id="u307" class="ax_default box_1">
    <div id="u307_div" class=""></div>
    <div id="u307_text" class="text ">
      <p><span>（门楼详址）</span></p>
    </div>
  </div>

  <!-- Unnamed (矩形) -->
  <div id="u308" class="ax_default box_3">
    <div id="u308_div" class=""></div>
  </div>

  <!-- Unnamed (矩形) -->
  <div id="u309" class="ax_default box_1">
    <div id="u309_div" class=""></div>
    <div id="u309_text" class="text ">
      <p><span>版权所有：公安局</span></p>
    </div>
  </div>

  <!-- Unnamed (下拉列表框) -->
  <div id="u310" class="ax_default droplist">
    <select id="nowInTownship" style="height: 25px; width: 60px" name="nowInTownship" >
      <option value="0">11</option>
    </select>
  </div>

  <!-- Unnamed (下拉列表框) -->
  <div id="u311" class="ax_default droplist">
    <select id="nowInCounty" style="height: 25px; width: 60px"  onclick="changship()" name="nowInCounty">
      <option value="0"></option>
    </select>
  </div>

  <!-- Unnamed (下拉列表框) -->
  <div id="u312" class="ax_default droplist">
    <select id="nowInCity" style="height: 25px; width: 60px" onclick="changCount()" name="nowInCity">
      <option value="0"></option>
    </select>
  </div>

  <!-- Unnamed (下拉列表框) -->
  <div id="u313" class="ax_default droplist">
    <select id="nowInProvince" style="height: 25px; width: 60px" onclick="changeCity()" name="nowInProvince">
      <option value="0"></option>
    </select>
  </div>

  <!-- Unnamed (矩形) -->
  <div id="u314" class="ax_default box_1">
    <div id="u314_div" class=""></div>
    <div id="u314_text" class="text ">
      <p><span>本人联系电话：</span></p>
    </div>
  </div>
  <!-- Unnamed (文本框) -->
  <div id="u315" class="ax_default text_field">
    <input id="u315_input" required="required" name="contactPhone" type="text" value=""/>
  </div>

  <!-- Unnamed (矩形) -->
  <div id="u316" class="ax_default box_1">
    <div id="u316_div" class=""></div>
    <div id="u316_text" class="text ">
      <p><span>工作单位：</span></p>
    </div>
  </div>

  <!-- Unnamed (文本框) -->
  <div id="u317" class="ax_default text_field">
    <input id="u317_input" required="required" name="workingUnit" type="text" value=""/>
  </div>


  <!-- Unnamed (矩形) -->
  <div id="u319" class="ax_default box_1">
    <div id="u319_div" class=""></div>
    <div id="u319_text" class="text ">
      <p><span>从业状况：</span></p>
    </div>
  </div>

  <!-- Unnamed (单选按钮) -->
  <div id="u320" class="ax_default radio_button">
    <label for="u320_input" style="position: absolute; left: 0px;">
      <div id="u320_text" class="text ">
        <p><span>国家机关</span></p>
      </div>
    </label>
    <input id="u320_input" type="radio" value="36" name="workingConditions"/>
  </div>

  <!-- Unnamed (单选按钮) -->
  <div id="u321" class="ax_default radio_button">
    <label for="u321_input" style="position: absolute; left: 0px;">
      <div id="u321_text" class="text ">
        <p><span>企、事业单位</span></p>
      </div>
    </label>
    <input id="u321_input" type="radio" value="37" name="workingConditions"/>
  </div>

  <!-- Unnamed (单选按钮) -->
  <div id="u322" class="ax_default radio_button">
    <label for="u322_input" style="position: absolute; left: 0px;">
      <div id="u322_text" class="text ">
        <p><span>自由职业</span></p>
      </div>
    </label>
    <input id="u322_input" type="radio" value="38" name="workingConditions"/>
  </div>

  <!-- Unnamed (单选按钮) -->
  <div id="u323" class="ax_default radio_button">
    <label for="u323_input" style="position: absolute; left: 0px;">
      <div id="u323_text" class="text ">
        <p><span>民营（个体）</span></p>
      </div>
    </label>
    <input id="u323_input" type="radio" value="39" name="workingConditions"/>
  </div>

  <!-- Unnamed (单选按钮) -->
  <div id="u324" class="ax_default radio_button">
    <label for="u324_input" style="position: absolute; left: 0px;">
      <div id="u324_text" class="text ">
        <p><span>离（退）休</span></p>
      </div>
    </label>
    <input id="u324_input" type="radio" value="40" name="workingConditions"/>
  </div>

  <!-- Unnamed (单选按钮) -->
  <div id="u325" class="ax_default radio_button">
    <label for="u325_input" style="position: absolute; left: 0px;">
      <div id="u325_text" class="text ">
        <p><span>无业</span></p>
      </div>
    </label>
    <input id="u325_input" type="radio" value="43" name="workingConditions"/>
  </div>

  <!-- Unnamed (单选按钮) -->
  <div id="u326" class="ax_default radio_button">
    <label for="u326_input" style="position: absolute; left: 0px;">
      <div id="u326_text" class="text ">
        <p><span>其他</span></p>
      </div>
    </label>
    <input id="u326_input" type="radio" value="44" name="workingConditions" checked="checked"/>
  </div>

  <!-- Unnamed (单选按钮) -->
  <div id="u327" class="ax_default radio_button">
    <label for="u327_input" style="position: absolute; left: 0px;">
      <div id="u327_text" class="text ">
        <p><span>学生</span></p>
      </div>
    </label>
    <input id="u327_input" type="radio" value="41" name="workingConditions" />
  </div>

  <!-- Unnamed (单选按钮) -->
  <div id="u328" class="ax_default radio_button">
    <label for="u328_input" style="position: absolute; left: 0px;">
      <div id="u328_text" class="text ">
        <p><span>农民</span></p>
      </div>
    </label>
    <input id="u328_input" type="radio" value="42" name="workingConditions" />
  </div>
  <input id="id" type="hidden">
  </form>




  <!-- Unnamed (矩形) -->
  <div id="u335" class="ax_default button">
    <div id="u335_div" class=""></div>
    <div id="u335_text" class="text ">
      <span><a onclick="peiou()" class="baocun">保存</a></span>
    </div>
  </div>

</div>
</body>
</html>
<script>
  var id = "";

  $(function () {
      $.ajaxSettings.async = false;
      $.getJSON("/selectProvince",{},function (data) {
          $("#nowInProvince").empty();
          var sheng='<option value="">请选择</option>';
          for(var i=0;i<data.length;i++){
              var s=data[i];
            sheng+='<option value="'+s.code+'">'+s.name+'</option>';
          }
          $("#nowInProvince").append(sheng);
      })
      if(location.href.split("&spouse=").length>1){
          id = location.href.split("&spouse=")[1];
          findSpouseById(id);
      }
  })
  function changeCity() {
      $.ajaxSettings.async = false;
      var code=$("#nowInProvince").val();
      $.getJSON("/selectCity",{"code":code},function (data) {
          $("#nowInCity").empty();
          var shi='<option value="">请选择</option>';
          for (var i=0;i<data.length;i++){
              var s=data[i];
              shi+='<option value="'+s.code+'">'+s.name+'</option>';
          }
          $("#nowInCity").append(shi);
      })
  }
  function changCount() {
      $.ajaxSettings.async = false;
      var code=$("#nowInCity").val();
      $.getJSON("/selectCounty",{"code":code},function (data) {
          $("#nowInCounty").empty();
          var xian='<option value="">请选择</option>';
          for (var i=0;i<data.length;i++){
              var s=data[i];
              xian+='<option value="'+s.code+'">'+s.name+'</option>';
          }
          $("#nowInCounty").append(xian);
      })
  }
  function changship() {
      $.ajaxSettings.async = false;
      var code=$("#nowInCounty").val();
      $.getJSON("/selectTownship",{"code":code},function (data) {
          $("#nowInTownship").empty();
          var ship='<option value="">请选择</option>';
          for(var i=0;i<data.length;i++){
              var s=data[i];
              ship+='<option value="'+s.code+'">'+s.name+'</option>';
          }
          $("#nowInTownship").append(ship);
      })
  }
  function peiou() {
    var formdata= new FormData($("#form2")[0]);
    var personalId = location.href.split("personalId=")[1];
    if(personalId.includes("&")){
        personalId = personalId.split("&")[0];
    }
    formdata.append("personalId",personalId);
      console.log(formdata);

      $.ajax({
          url:"/inserts",
          data:formdata,
          type:"post",
          async:false,
          dataType:"json",
          processData:false,
          contentType:false,
          success:function (data) {
              $("#id").val(data.id);
              alert("添加成功");
          }

      })
  }
  function findSpouseById(id) {
      $.ajax({
          url:"/findSpouseById",
          data:{id:id},
          dataType:"json",
          type:"post",
          async:false,
          success:function(data) {
              $("input[name='name']").val(data.name);
              $("input[name='identify']").val(data.identify);
              $("select[name='sex']").val(data.sex);
              $("select[name='nowInProvince']").val(data.nowInProvince);
              changeCity();
              $("select[name='nowInCity']").val(data.nowInCity);
              changCount();
              $("select[name='nowInCounty']").val(data.nowInCounty);
              changship();
              $("select[name='nowInTownship']").val(data.nowInTownship);
              $("input[name='nowInVillage']").val(data.nowInVillage);
              $("input[name='detailedAddress']").val(data.detailedAddress);
              $("input[name='workingUnit']").val(data.workingUnit);
              $("input[name='contactPhone']").val(data.contactPhone);
              $.each($("input[name='workingConditions']"),function(index,item) {//遍历单选框
                  if($(item).val()==data.workingConditions){//如果为要选的值
                      $(item).attr("checked","checked");//赋值
                  }
              })
              $("#id").val(data.id);
          }
      })
  }
  /**
   * 跳转到个人信息，传个人信息id
   */
  function toPersonalMessage() {
      var url = location.href; //获取url中"?"符后的字串
      var personalId = url.split("=")[1].split("&")[0];
      if($("#id").val()!=null&&$("#id").val()!=""){
          window.location = "/toPersonalInformation?id="+personalId+"&spouse="+$("#id").val();
      }else {
          window.location = "/toPersonalInformation?id="+personalId;
      }
  }
</script>